#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:

    vector<int>path;
    vector<vector<int>>ret;
    vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
        dfs(candidates, target, 0);

        return ret;
    }
    void dfs(vector<int>& candidates, int target, int sum)
    {
        if (sum >= target)
        {
            vector<int>v = path;
            sort(v.begin(), v.end());
            if (sum == target && find(ret.begin(), ret.end(), v) == ret.end()) ret.push_back(v);
            return;
        }
        for (int i = 0; i < candidates.size(); i++)
        {
            path.push_back(candidates[i]);
            dfs(candidates, target, sum + candidates[i]);
            path.pop_back();
        }
    }
};